home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7986 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: gettimeofday() makes me mad !
  5. Date: 28 Feb 1996 11:38:23 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4h2avfINNd6a@anvil.ugrad.cs.ubc.ca>
  8. References: <4gnkth$4on@piston.ecp.fr> <4gu1ue$39m@news-f.iadfw.net> <fcusack-2802961119240001@mudskipper.cac.psu.edu>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <fcusack-2802961119240001@mudskipper.cac.psu.edu>,
  12. frank. <fcusack@tdx.org> wrote:
  13.  >In article <4gu1ue$39m@news-f.iadfw.net>, alpet@airmail.net (Adam
  14.  >Peterson) wrote:
  15.  >
  16.  >> 
  17.  >> >PROBLEM : I'm trying to make a little program which must repeat an
  18.  >> >action every .2 second for example ( less than 1 sec anyway). time()
  19.  >> >wouldn't fit, so I searched and found the function gettimeofday() in
  20.  >> 
  21.  >> You are on a Unix system, any reason you are not using 'sleep'?
  22.  >> 
  23.  >
  24.  >sleep only works in whole seconds.
  25.  
  26. The age-old answer is to use the select() call, with zero for the number of
  27. file descriptors to poll, a null pointer for all three file descriptor sets,
  28. and a pointer to a timeval structure containing your desired sleep delay.
  29. I think that a lot of new UNIX programmers still discover this independently.
  30.  
  31. In any case, this is for comp.unix.programmer. If the original poster had gone
  32. there and read the FAQ's, I'm sure his question would have been answered.
  33. -- 
  34.  
  35.